package com.itheima.springboot.dao;

import com.itheima.springboot.domain.Course;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CourseDao {

    @Results({
            @Result(column = "cid", property = "cid"),
            @Result(column = "cname", property = "cname"),
            @Result(property = "students",
                    column = "sid",
                    javaType = List.class,
                    many = @Many(select = "com.itheima.springboot.dao.StudentDao.findBySid"))
    })
    @Select("select * from course c ,stu_co sc where c.cid =sc.cid")
    List<Course> findAll();
}
